import request from '@/config/axios'

// 工艺路线信息 VO
export interface RouteVO {
  routeName: string // 工艺路线名称
  status: number // 状态开关(1: 启用, 0: 禁用)
  routeProcessRels:[]
}

// 工艺路线信息 API
export const RouteApi = {
  // 查询工艺路线信息分页
  getRoutePage: async (params: any) => {
    return await request.get({ url: `/opticore/route/page`, params })
  },

  // 查询工艺路线信息详情
  getRoute: async (id: number) => {
    return await request.get({ url: `/opticore/route/get?id=` + id })
  },

  // 新增工艺路线信息
  createRoute: async (data: RouteVO) => {
    return await request.post({ url: `/opticore/route/create`, data })
  },

  // 修改工艺路线信息
  updateRoute: async (data: RouteVO) => {
    return await request.put({ url: `/opticore/route/update`, data })
  },

  // 删除工艺路线信息
  deleteRoute: async (id: number) => {
    return await request.delete({ url: `/opticore/route/delete?id=` + id })
  },

  // 导出工艺路线信息 Excel
  exportRoute: async (params) => {
    return await request.download({ url: `/opticore/route/export-excel`, params })
  },

// ==================== 子表（工艺路线工序关联） ====================

  // 获得工艺路线工序关联列表
  getRouteProcessRelListByRouteId: async (routeId) => {
    return await request.get({ url: `/opticore/route/route-process-rel/list-by-route-id?routeId=` + routeId })
  },
}
